package com.zsrt.java.day20161226.zsh.demo04;

import java.util.Scanner;

public class Demo01 {
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		System.out.println("输入一个不大于5位数的整数：");
		int number=input.nextInt();
		input.close();
		
		if(number>99999||number<0){
			System.out.println("输入的整数不符合要求");	
		}else if(number/10000>=1){
			int[] arrays = new int[5];
			int gws=gw(number);
			arrays[0]=gws;
			int sws=sw(number);
			arrays[1]=sws;
			int bws=bw(number);
			arrays[2]=bws;
			int qws=qw(number);
			arrays[3]=qws;
			int wws=ww(number);
			arrays[4]=wws;
			System.out.println("你输入的整数是一个5位数，逆序为：");
			print(arrays);
		}else if(number/1000>=1){
			int[] arrays = new int[4];
			int gws=gw(number);
			arrays[0]=gws;
			int sws=sw(number);
			arrays[1]=sws;
			int bws=bw(number);
			arrays[2]=bws;
			int qws=qw(number);
			arrays[3]=qws;
			System.out.println("你输入的整数是一个4位数，逆序为：");
			print(arrays);
		}else if(number/100>=1){
			int[] arrays = new int[3];
			int gws=gw(number);
			arrays[0]=gws;
			int sws=sw(number);
			arrays[1]=sws;
			int bws=bw(number);
			arrays[2]=bws;

			System.out.println("你输入的整数是一个3位数，逆序为：");
			print(arrays);
		}else if(number/10>=1){
			int[] arrays = new int[2];
			int gws=gw(number);
			arrays[0]=gws;
			int sws=sw(number);
			arrays[1]=sws;

			System.out.println("你输入的整数是一个2位数，逆序为：");
			print(arrays);
		}else if(number>0&number<10){
			int[] arrays = new int[1];
			int gws=gw(number);
			arrays[0]=gws;

			System.out.println("你输入的整数是一个1位数");
			print(arrays);
		}	
	}
	
	public static int gw(int number){
		int qgw=number%10;
		return qgw;
	}
	
	public static int sw(int number){
		int qsw=number%100/10;
		return qsw;
	}
	
	public static int bw(int number){
		int qbw=number%1000/100;
		return qbw;
	}
	
	public static int qw(int number){
		int qbw=number%10000/1000;
		return qbw;
	}
	
	public static int ww(int number){
		int qww=number/10000;
		return qww;
	}
	
	public static void print(int[] arrays){
		for(int index = 0; index<arrays.length; index++){
			int val = arrays[index];
			if(index == arrays.length -1){
				System.out.print(val);
				break;
			}
			System.out.print(val + ", ");
		}
		System.out.println();
	}
	
}
